home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Windows & Frames / time-controlled-popunder.izs < prev    next >
Text File  |  2005-07-29  |  5KB  |  168 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Time Controlled Popunder Window
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION> This versatile popunder window script allows you to precisely control how often the window pops under, in terms of "once every x hours". For example, specifying 24 hours translates into the script popping under only once a day.
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>windows, remotes, frames<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <script type="text/javascript">
  14.  
  15. //1) specify URLs to randomly select from and pop-under:
  16. //To display a single URL, just remove all but the first entry below:
  17. var popunder=new Array()
  18. popunder[0]="http://www.freewarejava.com"
  19. popunder[1]="http://www.dynamicdrive.com"
  20. popunder[2]="http://www.webmasterpick.com"
  21. popunder[3]="http://www.codingforums.com"
  22.  
  23. //2) specify popunder window features
  24. //set 1 to enable a particular feature, 0 to disable
  25. var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"
  26.  
  27. //3) Control frequency of the pop up:
  28. //"always", for every time page loads OR
  29. //"x hours" for once per x hours, where x is an integer (ie: 12 hours)
  30.  
  31. var popfrequency="24 hours"
  32.  
  33. ///No editing beyond here required/////
  34.  
  35. function get_cookie(Name) {
  36.   var search = Name + "="
  37.   var returnvalue = "";
  38.   if (document.cookie.length > 0) {
  39.     offset = document.cookie.indexOf(search)
  40.     if (offset != -1) { // if cookie exists
  41.       offset += search.length
  42.       // set index of beginning of value
  43.       end = document.cookie.indexOf(";", offset);
  44.       // set index of end of cookie value
  45.       if (end == -1)
  46.          end = document.cookie.length;
  47.       returnvalue=unescape(document.cookie.substring(offset, end))
  48.       }
  49.    }
  50.   return returnvalue;
  51. }
  52.  
  53. function resetcookie(){
  54. var expireDate = new Date()
  55. expireDate.setHours(expireDate.getHours()-10)
  56. document.cookie = "tcpopunder=;path=/;expires=" + expireDate.toGMTString()
  57. }
  58.  
  59. function loadornot(){
  60. if (get_cookie('tcpopunder')==''){
  61. loadpopunder()
  62. var expireDate = new Date()
  63. expireDate.setHours(expireDate.getHours()+parseInt(popfrequency))
  64. document.cookie = "tcpopunder="+parseInt(popfrequency)+";path=/;expires=" + expireDate.toGMTString()
  65. }
  66. }
  67.  
  68. function loadpopunder(){
  69. win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"",winfeatures)
  70. win2.blur()
  71. window.focus()
  72. }
  73.  
  74. if (popfrequency=="always"){
  75. resetcookie()
  76. loadpopunder()
  77. }
  78. else{
  79. if (get_cookie('tcpopunder')!=parseInt(popfrequency))
  80. resetcookie()
  81. loadornot()
  82. }
  83. </script>
  84.  
  85.  
  86. <!-- END OF SCRIPT -->
  87. <!/SCRIPT>
  88.  
  89. <!PREVIEW>
  90. <!-- START OF SCRIPT -->
  91. <script type="text/javascript">
  92.  
  93. //1) specify URLs to randomly select from and pop-under:
  94. //To display a single URL, just remove all but the first entry below:
  95. var popunder=new Array()
  96. popunder[0]="http://www.freewarejava.com"
  97. popunder[1]="http://www.dynamicdrive.com"
  98. popunder[2]="http://www.webmasterpick.com"
  99. popunder[3]="http://www.codingforums.com"
  100.  
  101. //2) specify popunder window features
  102. //set 1 to enable a particular feature, 0 to disable
  103. var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"
  104.  
  105. //3) Control frequency of the pop up:
  106. //"always", for every time page loads OR
  107. //"x hours" for once per x hours, where x is an integer (ie: 12 hours)
  108.  
  109. var popfrequency="24 hours"
  110.  
  111. ///No editing beyond here required/////
  112.  
  113. function get_cookie(Name) {
  114.   var search = Name + "="
  115.   var returnvalue = "";
  116.   if (document.cookie.length > 0) {
  117.     offset = document.cookie.indexOf(search)
  118.     if (offset != -1) { // if cookie exists
  119.       offset += search.length
  120.       // set index of beginning of value
  121.       end = document.cookie.indexOf(";", offset);
  122.       // set index of end of cookie value
  123.       if (end == -1)
  124.          end = document.cookie.length;
  125.       returnvalue=unescape(document.cookie.substring(offset, end))
  126.       }
  127.    }
  128.   return returnvalue;
  129. }
  130.  
  131. function resetcookie(){
  132. var expireDate = new Date()
  133. expireDate.setHours(expireDate.getHours()-10)
  134. document.cookie = "tcpopunder=;path=/;expires=" + expireDate.toGMTString()
  135. }
  136.  
  137. function loadornot(){
  138. if (get_cookie('tcpopunder')==''){
  139. loadpopunder()
  140. var expireDate = new Date()
  141. expireDate.setHours(expireDate.getHours()+parseInt(popfrequency))
  142. document.cookie = "tcpopunder="+parseInt(popfrequency)+";path=/;expires=" + expireDate.toGMTString()
  143. }
  144. }
  145.  
  146. function loadpopunder(){
  147. win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"",winfeatures)
  148. win2.blur()
  149. window.focus()
  150. }
  151.  
  152. if (popfrequency=="always"){
  153. resetcookie()
  154. loadpopunder()
  155. }
  156. else{
  157. if (get_cookie('tcpopunder')!=parseInt(popfrequency))
  158. resetcookie()
  159. loadornot()
  160. }
  161. </script>
  162.  
  163.  
  164.  
  165. <!-- END OF SCRIPT -->
  166. <!/PREVIEW>
  167.  
  168. <!RELATED>NONE<!/RELATED>